/*
 * MIXPLAY.H Version 1.00 (C)1996 HUDSON SOFT
 * MIX 再生プログラム用ヘッダーファイル(MIXPLAY.H)
 */

#ifndef __MIXPLAY_H
#define __MIXPLAY_H

#define	TRUE	1
#define	FALSE	0

#ifndef	NULL
#define	NULL	((void *)0)
#endif

enum {
    EM_OK = 0, EM_TO
};

typedef struct FILE_LIST {
    struct FILE_LIST far *next;		/* 次のポインタ。NULL で終り */
    unsigned long	lsize;		/* 論理サイズ。2048 切り上げ */
    unsigned long	psize;		/* 実サイズ */
    unsigned long	sec_top;	/* 先頭セクタ */
    unsigned long	sec_end;	/* 最終セクタ */
    unsigned long	sec_len;	/* セクタ長 */
    unsigned char	track;		/* トラック番号 */
    unsigned char	type;		/* トラック属性 */
    unsigned char	name[2];	/* DOS ファイル名 */
} filelist;

typedef struct STRB {
    unsigned char	code;
    unsigned char	stat;
    unsigned char	host_no;
    unsigned char	cmd;
    unsigned char	data[36];
} strb;

typedef struct SECT {
    unsigned char	sec0;
    unsigned char	sec1;
    unsigned char	sec2;
    unsigned char	sec3;
} sect;

typedef struct TOC_HEAD {
    unsigned char	len0;
    unsigned char	len1;
    unsigned char	st_trk;
    unsigned char	ed_trk;
} toc_head;

typedef struct TOC_INFO {
    unsigned char	rsv0;
    unsigned char	adr_ctrl;
    unsigned char	trk_no;
    unsigned char	rsv1;
    sect		sec_dat;
} toc_info;

typedef struct SENSE_DATA {
    unsigned char	err_code;
    unsigned char	rsv0;
    unsigned char	sns_key;
    sect		sec_dat;
    unsigned char	add_len;
    unsigned char	dev_id;
    unsigned char	rsv_sub_err;
    unsigned char	rsv1;
    unsigned char	rsv2;
    unsigned char	sub_err;
    unsigned char	rsv3;
    unsigned char	rsv4;
    unsigned char	rsv5;
    unsigned char	rsv6;
    unsigned char	rsv7;
} sense_data;

extern filelist	far *file_list_top;
extern char *load_file;
extern int debug_flag;
extern int eml_status;

/* list.c */
void add_file_list(char *name);
void free_file_list(void);
filelist far *get_sec_list(unsigned long sec);
filelist far *get_track_list(int trk);

/* usage.c */
void error(char *mess);
void title(void);
void usage(char *mess);

/* misc.c */
void dprintf(char *fmt, ...);
int file_exist_check(char *file);
unsigned long get_file_size(char *file);
int bcd2bin(int bcd);
int bin2bcd(int bin);
void far *my_malloc(unsigned long sz);
void my_free(void far *ptr);
void my_seek(int fhd,long ofs,int from);
int my_ioctl(int fhd,int fnc,void far *buf,int len);
void change_file_ext(char *src,char *name,char *ext,char *buf);

/* mixmain.c */
void arg_check(int argc,char **argv);
int main(int argc,char *argv[]);

/* download.c */
void pio_break(void);
void _sleep(int sec);
void pio_reset(void);
int pio_stat(void);
void pio_init(void);
void pio_mpoke(unsigned long adr,int len,char far *buf);
void pio_download(void);
void pio_run(void);
void pio_close(void);
void load_exec(void);

/* cdrom.c */
void asti_call(void);
void tgfx_open(void);
void tgfx_init(void);
int tgfx_sel(int *msgp);
int tgfx_wait(void);
int tgfx_phase(void);
int tgfx_send_data_byte(void far *datap,int len);
int tgfx_send_data_block(void far *datap,int len);
void tgfx_getcmd(void);
int tgfx_getmes(void);
void tgfx_sndmes(int mes);
void tgfx_endcmd(void);
int get_max_track(void);
void set_sec_data1(unsigned long sec,int msf,sect *dp);
int get_track_no(unsigned long sec);
void set_sec_data2(unsigned long sec,int typ,sect *dp);
unsigned long get_sec_data2(sect *dp,int typ);
int set_start_sec(int track,int msf,sect *dp);
int request_sense(void);
int read_toc(void);
int read_extended(void);
int exec_scsi_cmd(void);
void tgfx_close(void);
void cdrom_eml(void);

#endif	/* __MIXPLAY_H */
